package org.springframework.web.servlet.ajax.json;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * @author Charles Tassoni
 */

public class JsonUtil {

	public static JSONArray toJson(List<Map> maps) {
		JSONArray arr = new JSONArray();
		for (Map map : maps) {
			JSONObject obj = new JSONObject(map);
			arr.put(obj);
		}

		return arr;
	}

	public static String mapToJson(Map map) {
		RespectsOrderJSONObject j = new RespectsOrderJSONObject();
		return j.toString(map);
	}


}
